﻿<cfscript>
/** 
* File System Object service
* 
* @hint "File System Object service" 
*/ 

component 
	displayname="public.service.util.fileSystemObject" 
	output=false 
	{
	
	/**
	* @hint "初始化对象"
	*/
	public public.service.util.fileSystemObject function init() output=false {
		return this;
	}
	
	/**
	* @hint "使用UTF-8编码写入文件"
	* 
	* @sFilePath "写入文件的物理路径"
	* @sInput "文件字符串内容"
	*/
	public void function fileWriteUT8(required string sFilePath, required string sInput) output=false {
		
		var jWriter = "";
		var jFile = createobject("java", "java.io.File").init(arguments.sFilePath);
		var jStream = createobject("java", "java.io.FileOutputStream").init(jFile);
		
		jStream.write(239);
		jStream.write(187);
		jStream.write(191);
		
		jWriter = createobject("java", "java.io.OutputStreamWriter");
		jWriter.init(jStream, "UTF-8");
		jWriter.write(javaCast("String", trim(arguments.sInput)));
		
		jWriter.flush();
		jWriter.close();
		jStream.close();
		
	}
	
}

</cfscript>